#ifndef _BARCODE_H_
#define _BARCODE_H_

#define MAX_BAR_STR_LEN 32
#define MAX_CHAN_NUM_BAR 4

typedef struct _barcode_str
{
    char barStr[MAX_BAR_STR_LEN];
    unsigned short checkCode;
}barcode_str;

typedef enum
{
    BARCODE_FIRST_PART,
    BARCODE_MIDDLE_PART,
    BARCODE_LAST_PART,
}en_barcode_part_type;

const int Barcode_Num[MAX_CHAN_NUM_BAR] = {48,48,4,4};

class CBarcode
{
private:
    barcode_str * m_bar_code_all[MAX_CHAN_NUM_BAR];
    int m_currBarcodeNum[MAX_CHAN_NUM_BAR];

    barcode_str  m_barcodeStrBuff[MAX_CHAN_NUM_BAR];
    int  m_CurrIndexStrBuff[MAX_CHAN_NUM_BAR];

public:
    //typeIn can be the first part, the last part, or middle part
    int addPartStr(unsigned char chanNum,unsigned char typeIn,unsigned char * strIn, unsigned char lenStr); 

    virtual ~ CBarcode();

    CBarcode();

    int init_one_chan(int chanNum);
    //the following opration just proc the cmd from upper,
    //report the barcode and clean them.
    int stop_one_chan(int chanNum);
    //the following operation proc the signal of drawer mag lock,
    //compare the content of barcode string, 
    //if drawer id is wrong, here should alarm, and do not report the barcode.
    //if the drawer id is correct, report the barcode strings up. 
    int scan_end(int drawerId);

    //write scan result to file
    void writeToFile(int chanNum);

};

extern CBarcode * g_barcode_handle;

extern const char * strPurifyReagent[2];

#endif